<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../layui-v2.4.3/layui/css/layui.css" media="all">
</head>
<body>
<div class="layui-container" style="margin-top: 30px;">
<table class="layui-hide" id="test" lay-filter="test"></table>
</div>

              
          
<script src="../../js/jquery.js"></script>
<script src="../../layui-v2.4.3/layui/layui.js"></script>
<script src="../../js/jquery.cookie.js"></script>
<script src="../../js/jquery.params.js"></script>

<script>
layui.use('table', function(){
  var table = layui.table;
  var con = {"context":"","condition":""}
  
	var claId = $.query.get("claId");
	var expId =$.query.get('expId');
  table.render({
  	id: 'studentScore'
    ,elem: '#test' 
    ,toolbar: '#toolbarDemo'
    ,height: 500
    ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
      layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
      ,groups: 1 //只显示 1 个连续页码
      ,limits:[10, 20, 30, 40, 50,99999]
    }
    ,url: 'http://localhost:8080/teacher/score/getInfo.do?claId='+claId+"&expId="+expId
    ,where: { 
    	uid: $.cookie("uid"),
    }
    ,page: true //开启分页
    ,cols: [[ //表头 
      {field: 'stuNum', title: '学号', sort: true,fixed: 'left'}
      ,{field: 'stuName', title: '学生姓名'}
      ,{field: 'stuClass', title: '学生班级', sort: true}
      ,{field: 'expName', title: '试验名称', sort: true}
      ,{field: 'isSame', title: '是否相似', templet:function(d){if(d===1)return '相似';else return "不相似";}}
      ,{field: 'sameGroup', title: '相似分组', sort: true}
      ,{field: 'behScore', title: '行为异常', sort: true,templet:function(d){if(d===1)return '异常';else return "无异常";}}
      ,{field: 'expScore', title: '试验分数',edit: 'text'}
    ]]
  });  
  
  table.on('toolbar(test)', function(obj){
    var checkStatus = table.checkStatus(obj.config.id);
    switch(obj.event){
      case 'isAll':
      	con.condition = $("#queryCondition").val();
      	con.context = $("#queryContext").val();
      	
				table.reload('studentScore',{
       		where:{
						uid: $.cookie("uid"),
			    	condition: $("#queryCondition").val(),
			    	context : $("#queryContext").val(),
        	},
        	page: {
          	curr: 1,
        	}
        });
      break;
    };
  });
  
	table.on('edit(test)', function(obj){ //注：edit是固定事件名，test是table原始容器的属性 lay-filter="对应的值"
		$.ajax({
			type: "get",
			url: "http://localhost:8080/teacher/score/editInfo.do",
			dataType: "json",
			async: false,
			data:{
				expId:obj.data['expId'],
				stuId:obj.data['stuId'],
				expScore:obj.data['expScore'],
				uid: $.cookie("uid")
			},
			success: function(data) {
				alert("success");
				scores = data;
			}
		}); 
	});
  


});
</script>

</body>
</html>